<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Class site_model extends CI_Model
 * ----------------------------------------------------------
 * Author:		Michael Lamb
 * Date:		February 2012
 * Version:		0.1
 * 
 * ----------------------------------------------------------
 * Synopsis:
 * ---------
 * Public CMS content model
 * 
 * Extracts the menu from the database
 *
 * Extracts page meta details for all pages from the database
 *
 * Extracts content for CMS pages from the database
 *
 * ----------------------------------------------------------
 * Methods:
 * --------
 * getMainMenu		Constructs the parent class
 * getPageContent	Loads CMS pages
 * 
 * ----------------------------------------------------------
 * Planned Changes:
 * ----------------
 * - Add metadata extraction method
 * 
 * ----------------------------------------------------------
 * Version History:
 * ----------------
 * 0.1
 * ---
 * - Main menu extraction
 * - CMS page content extraction
 *   
 * ----------------------------------------------------------
 * ##########################################################
 * ----------------------------------------------------------
 */
class Site_model extends CI_Model {
	/**
	 * Name: Site_model
	 * Scope: Public
	 * 
	 * @params:
	 * 		$params - array
	 */
	function getMainMenu($params)
	{
		extract($params,EXTR_SKIP);
		
		if(isset($menu)&&$menu!='')
		{
			$this->db->select('page_nodes.name');
			$this->db->select('override');
			$this->db->from('page_nodes');
			$this->db->join('menus', 'menus.menu_id = page_nodes.menu_id');
			$this->db->where('menus.name = "'.$menu.'"');
			$this->db->order_by('order', 'asc');
			$query = $this->db->get();
			
			return $query->result();
		}
		else
		{
			return false;
		}
		
	}
	
	/**
	 * Name: getPageContent
	 * Scope: Public
	 * 
	 * @params:
	 * 		$page_name - string
	 */
	function getPageContent($page_name)
	{
		
		$this->db->select('name, title, keywords, description, content');
		$this->db->from('pages');
		$this->db->where('name', $page_name);
		$query = $this->db->get();
		return $query->first_row();
	}
}
/* End of file site_model.php */
/* Location: ./application/models/site_model.php */